const http=require('http');
const server=http.createServer((req,res)=>{
    const path =req.url;
    if (path === '/') {
        res.writeHead(200, {"Content-type":"text/html;charset=utf-8"});
        res.end('<h1>欢迎信息</h1>');
      } else if (path === '/about') {
        res.writeHead(200, {"Content-type":"text/html;charset=utf-8" });
        res.end('<h1>关于页面的内容</h1>');
      } else if (path === '/contact') {
        res.writeHead(200, {"Content-type":"text/html;charset=utf-8"});
        res.end('<h1>联系页面的内容<h1>');
      } else {
        res.writeHead(404, {"Content-type":"text/html;charset=utf-8" });
        res.end('<h1>错误页面</h1>');
      }
})
server.listen(3001,()=>{
    console.log('服务器已启动，监听端口 3000');
})